In [6]:
%pylab inline
In [7]:
t = arange(0.0, 1.0, 0.01)
y1 = sin(2*pi*t)
y2 = sin(2*2*pi*t)
import pandas as pd
df = pd.DataFrame({'t': t, 'y1': y1, 'y2': y2})
df.head(10)
Out[7]:
In [8]:
from bokeh.plotting import figure, output_notebook, show
# output inline with notebook
output_notebook()
# create a new plot with a title and axis labels
p = figure(title="simple sine example", x_axis_label='t', y_axis_label='sin(2*pi*t)')
# add a line renderer with legend and line thickness
p.line(t, sin(2*pi*t), legend="Temp.", line_width=2)
# show the results
show(p)
Out[8]:
In [11]:
# this uses Bokeh for plotting + ipywidgets for widgets
# translation: no Bokeh server required
from ipywidgets import interact
import numpy as np
from bokeh.io import push_notebook
from bokeh.plotting import figure, show, output_notebook
x = np.linspace(0, 2*np.pi, 2000)
y = np.sin(x)
output_notebook()
p = figure(title="simple curvy example", plot_height=300, plot_width=600, y_range=(-5,5))
r = p.line(x, y, color="#2222aa", line_width=3)
def update(f, w=1, A=1, phi=0):
if f == "sin": func = np.sin
elif f == "cos": func = np.cos
elif f == "tan": func = np.tan
r.data_source.data['y'] = A * func(w * x + phi)
push_notebook() # only updates *last* shown object
interact(update, f=["sin", "cos", "tan"], w=(0,100), A=(1,5), phi=(0, 20, 0.1))
show(p)
Out[11]:
In [12]:
from bokeh.plotting import figure, output_file, show
# prepare some data
x = [0.1, 0.5, 1.0, 1.5, 2.0, 2.5, 3.0]
y0 = [i**2 for i in x]
y1 = [10**i for i in x]
y2 = [10**(i**2) for i in x]
output_notebook()
# create a new plot
p = figure(
tools="pan,box_zoom,reset,save",
y_axis_type="log", y_range=[0.001, 10**11], title="log axis example",
x_axis_label='sections', y_axis_label='particles'
)
# add some renderers
p.line(x, x, legend="y=x")
p.circle(x, x, legend="y=x", fill_color="white", size=8)
p.line(x, y0, legend="y=x^2", line_width=3)
p.line(x, y1, legend="y=10^x", line_color="red")
p.circle(x, y1, legend="y=10^x", fill_color="red", line_color="red", size=6)
p.line(x, y2, legend="y=10^x^2", line_color="orange", line_dash="4 4")
# show the results
show(p)
Out[12]: